// $Id: media.h 94 2011-10-19 12:48:16Z cedric.shih@gmail.com $
/*
 * Copyright 2011 Cedric Shih (cedric dot shih at gmail dot com)
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation; either version 2.1 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 */

#ifndef MEDIA_H_
#define MEDIA_H_

#ifdef __cplusplus
extern "C" {
#endif

#include <sys/tree.h>

#include "track.h"

struct niortsp_media {
	char *name;
	struct niortsp_track_list tracks;
	niortsp_media_describe_cb describe;
	void *cbarg;
	RB_ENTRY(niortsp_media) entry;
};

RB_HEAD(niortsp_media_map, niortsp_media);

struct zcbuffer;

int niortsp_media_describe(struct niortsp_media *media,
		u_int32_t session, const char *uri, struct zcbuffer *buffer);

int niortsp_media_map_add(struct niortsp_media_map *map, const char *name,
		struct niortsp_media **ptr);

void niortsp_media_map_remove(struct niortsp_media_map *map,
		struct niortsp_media *media);

struct niortsp_media *niortsp_media_map_find(struct niortsp_media_map *map,
		const char *name);

void niortsp_media_map_clear(struct niortsp_media_map *map);

int niortsp_media_compare(struct niortsp_media *a, struct niortsp_media *b);

RB_PROTOTYPE(niortsp_media_map, niortsp_media, entry, niortsp_media_compare);

#ifdef __cplusplus
}
#endif

#endif /* MEDIA_H_ */
